Skip to content

Conversation

@kleisauke
Copy link
Collaborator

@kleisauke kleisauke commented Jan 10, 2026

To ensure compatibility with Deno which requires explicit
identification of built-in Node.js modules.

When targeting Node.js versions older than 16 (e.g.
-sMIN_NODE_VERSION=150000), the node: prefix is removed using
a custom Babel plugin.

lgarron and others added 4 commits February 6, 2025 19:50
This makes the imports diistinguishable from the corresponding `npm` packages, which can help with:

- Development ergonomics:
  - Marking all `node:*` packages as external in a bundler.
  - Tracking the dependency graph
- Supply chain security (avoiding risks from name squatting).

The `node:` protocol prefix is supported in LTS versions all the way back to `node` 12: https://nodejs.org/api/esm.html#node-imports
This is an automatic change generated by tools/maint/rebaseline_tests.py.

The following (48) test expectation files were updated by
running the tests with `--rebaseline`:

```
codesize/test_codesize_cxx_ctors1.json: 149109 => 149119 [+10 bytes / +0.01%]
codesize/test_codesize_cxx_ctors2.json: 148513 => 148523 [+10 bytes / +0.01%]
codesize/test_codesize_cxx_except.json: 194578 => 194588 [+10 bytes / +0.01%]
codesize/test_codesize_cxx_except_wasm.json: 164093 => 164098 [+5 bytes / +0.00%]
codesize/test_codesize_cxx_except_wasm_legacy.json: 161751 => 161761 [+10 bytes / +0.01%]
codesize/test_codesize_cxx_lto.json: 125441 => 125451 [+10 bytes / +0.01%]
codesize/test_codesize_cxx_mangle.json: 258655 => 258665 [+10 bytes / +0.00%]
codesize/test_codesize_cxx_noexcept.json: 151526 => 151536 [+10 bytes / +0.01%]
codesize/test_codesize_cxx_wasmfs.json: 177088 => 177098 [+10 bytes / +0.01%]
test/codesize/test_codesize_file_preload.expected.js updated
codesize/test_codesize_file_preload.json: 24242 => 24252 [+10 bytes / +0.04%]
codesize/test_codesize_files_js_fs.json: 18654 => 18664 [+10 bytes / +0.05%]
codesize/test_codesize_files_wasmfs.json: 56055 => 56065 [+10 bytes / +0.02%]
codesize/test_codesize_hello_O0.json: 39358 => 39363 [+5 bytes / +0.01%]
codesize/test_codesize_hello_O1.json: 9020 => 9025 [+5 bytes / +0.06%]
codesize/test_codesize_hello_O2.json: 6246 => 6251 [+5 bytes / +0.08%]
codesize/test_codesize_hello_O3.json: 5942 => 5947 [+5 bytes / +0.08%]
codesize/test_codesize_hello_Os.json: 5932 => 5937 [+5 bytes / +0.08%]
codesize/test_codesize_hello_Oz.json: 5101 => 5106 [+5 bytes / +0.10%]
codesize/test_codesize_hello_dylink.json: 44425 => 44435 [+10 bytes / +0.02%]
codesize/test_codesize_hello_dylink_all.json: 822630 => 822655 [+25 bytes / +0.00%]
codesize/test_codesize_hello_export_nothing.json: 3215 => 3220 [+5 bytes / +0.16%]
codesize/test_codesize_hello_single_file.json: 5366 => 5371 [+5 bytes / +0.09%]
codesize/test_codesize_hello_wasmfs.json: 5942 => 5947 [+5 bytes / +0.08%]
codesize/test_codesize_libcxxabi_message_O3.json: 3612 => 3617 [+5 bytes / +0.14%]
codesize/test_codesize_libcxxabi_message_O3_standalone.json: 3702 => 3707 [+5 bytes / +0.14%]
codesize/test_codesize_mem_O3.json: 9610 => 9615 [+5 bytes / +0.05%]
codesize/test_codesize_mem_O3_grow.json: 9896 => 9901 [+5 bytes / +0.05%]
codesize/test_codesize_mem_O3_grow_standalone.json: 9649 => 9654 [+5 bytes / +0.05%]
codesize/test_codesize_mem_O3_standalone.json: 9507 => 9512 [+5 bytes / +0.05%]
codesize/test_codesize_mem_O3_standalone_lib.json: 8802 => 8807 [+5 bytes / +0.06%]
codesize/test_codesize_mem_O3_standalone_narg.json: 8835 => 8840 [+5 bytes / +0.06%]
codesize/test_codesize_mem_O3_standalone_narg_flto.json: 7777 => 7782 [+5 bytes / +0.06%]
codesize/test_codesize_minimal_64.json: 2679 => 2684 [+5 bytes / +0.19%]
test/codesize/test_codesize_minimal_O0.expected.js updated
codesize/test_codesize_minimal_O0.json: 20629 => 20634 [+5 bytes / +0.02%]
codesize/test_codesize_minimal_O1.json: 3510 => 3515 [+5 bytes / +0.14%]
codesize/test_codesize_minimal_O2.json: 2632 => 2637 [+5 bytes / +0.19%]
codesize/test_codesize_minimal_O3.json: 2368 => 2373 [+5 bytes / +0.21%]
codesize/test_codesize_minimal_Os.json: 2368 => 2373 [+5 bytes / +0.21%]
codesize/test_codesize_minimal_Os_mr.json: 572 => 577 [+5 bytes / +0.87%]
codesize/test_codesize_minimal_Oz-ctors.json: 2336 => 2341 [+5 bytes / +0.21%]
codesize/test_codesize_minimal_Oz.json: 2368 => 2373 [+5 bytes / +0.21%]
codesize/test_codesize_minimal_esm.json: 2504 => 2524 [+20 bytes / +0.80%]
codesize/test_codesize_minimal_pthreads.json: 27298 => 27313 [+15 bytes / +0.05%]
codesize/test_codesize_minimal_pthreads_memgrowth.json: 27721 => 27737 [+16 bytes / +0.06%]
codesize/test_codesize_minimal_wasmfs.json: 2368 => 2373 [+5 bytes / +0.21%]
codesize/test_unoptimized_code_size.json: 180979 => 180994 [+15 bytes / +0.01%]

Average change: +0.11% (+0.00% - +0.87%)
```
@sbc100
Copy link
Collaborator

sbc100 commented Jan 10, 2026

When you say "To ensure compatibility with To ensure compatibility with Deno and other runtimes that require
explicit identification..", when is it actually required? We do test our output on both deno and bun and they both seem to run the current output OK.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 10, 2026

Assuming there are some tests that fails under Deno or Bun prior to this change, could you add one or two of them to the list of tests we run under Bun:

test_targets: "core0.test_hello_world"

@kleisauke
Copy link
Collaborator Author

Here's a test case that currently fails on Deno:

$ emcc test/hello_world.c -sEXPORT_ES6 --extern-post-js test/modularize_post_js.js
$ deno a.out.js
error: Uncaught (in promise) TypeError: Import "module" not a dependency
    at file:///home/kleisauke/emscripten/a.out.js:83:42

  const { createRequire } = await import('module');
                            ^
    at async Module (file:///home/kleisauke/emscripten/a.out.js:83:29)
$ deno -v
deno 2.6.4

I thought Bun had the same behavior, but it appears to work correctly there. I'll revise the PR description accordingly.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 11, 2026

Oh, I thought we had some basic Deno testing but it looks like we only have that for Bun.

Would you mind adding some basic Deno testing as a separate PR, and then this change can increease the testing to include ES6.

The initial version #25947 has some Bun testing and I asked if @Macil would be interested in landing that separately, but maybe you want to do it @kleisauke?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants